<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>详情</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-
scale=1, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../css/y_index.css" />
    <style>
    .express {
        display: none;
    }

    .state {
        color: #fb6d74;
    }
    </style>
</head>

<body>
    <div class="bigBox">
        <div class="container">
            <div class="mainBox"></div>
            <div class="main_btn">确认收货</div>
        </div>
    </div>
</body>

</html>
<script src="../js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/dlc.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.0/alipayjsapi.inc.min.js"></script>
<!--公司的常用函数封装-->
<script type="text/javascript">
dlc_request('/api/myOrder/OrderDetailList', { orderNo: getUrlParam('order') }, function(res) {
    console.log(res);
    if (res.code == 1) {
        var str = '';
        var data = res.data[0];
        console.log(data);
        str += '<li class="p20 bw bdb">订单状态：<span class="state" style="color:'+(data.status == 1 ? '#fb6d74' : data.status == 2 ? '#7cc0f0' : '#999')+'">' + (data.status == 0 ? '待付款' : data.status == 1 ? '待发货' : data.status == 2 ? '待收货' : '已完成') + '</span></li> <li class="bw p20 flex_sb mt20 bdb express" onclick="express(this)" data-id=' + data.orderNo + '> <ul class="flex_a"> <img src="../img/icon_1.png" style="width:.41rem;height: .3rem;" /> <li class="ml20 flex flex_column"> <span class="font15 kdMsg"></span> <span class="col9 mt20 ftime"></span> </li> </ul> <img src="../img/y_arrow_right1.png" style="width:.14rem;height: .2rem;" /> </li> <li class="flex_sb ais bw p20 mb20"> <div class="flex_aj"> <img src="../img/y_map1.png" style="width: .27rem;height: .3rem;" /> <ul class="flex flex_column ml20"> <li class="font15">收货人：' + data.name + '</li> <li class="col9 mt20">' + data.addr + '</li> </ul> </div> <span>' + data.phone + '</span> </li> '
        var list = res.data[0].goodsInfo;
        list.forEach((item, index) => {
            str += '<li class="p20 flex_sb aie bw list bdb p20"><div class="flex_a goodsInfo bw" data-id="' + item.goodsId + '"> <img src="' + item.imgUrl + '" style="width: 1.5rem;height: 1.5rem;" /> <em class="flex flex_column ml20"> <span class="font15">' + item.goodsName + '</span> <span class="col9 mt20">分类：' + item.categoryName + '</span> <span class="c4 mt20">￥' + Number(item.price).toFixed(2) + '</span> </em><span class="col9">x' + (item.orderNum ? item.orderNum : '0') + '</span> </li> </div>';
        })
        str += '<li class="flex_sb p20 bw"> 商品总价<span class="col9">￥' + (data.realPayment - data.freight) + '</span><li class="flex_sb p20 bw"> 运费<span class="col9">￥' + data.freight + ' </span></li> <li class="flex_sb p20 bw"> 实付款<span class="c4">￥' + Number(data.realPayment).toFixed(2) + '</span> </li> <li class="p20 mt20 bw flex flex_column"> <span>订单编号：<i class="ml20 col9">' + getUrlParam('order') + '</i></span> <span class="mt20">交易号：<i class="ml20 col9">' + (data.transactionNo ? data.transactionNo : '商品未付款') + '</i></span> <span class="mt20">创建时间：<i class="ml20 col9">' + (data.createTime ? format(data.createTime, "Y-m-d H:i:s") : '') + '</i></span> <span class="mt20">付款时间：<i class="ml20 col9">' + (data.payTime ? format(data.payTime, "Y-m-d H:i:s") : '商品未付款') + '</i></span> </li> <li class="p20 mt20 bw flex flex_column express"> <span class="font15 fw bdb">物流信息</span> <span class="mt20">物流公司：<i class="ml20 col9">' + (data.logisticsName ? data.logisticsName : '') + '</i></span> <span class="mt20">物流单号：<i class="ml20 col9">' + (data.logisticsNo ? data.logisticsNo : '') + '</i></span> </li>';
        dlc_request('/api/express/queryExpressLastMsg', { 'nu': data.logisticsNo }, function(res) {
            console.log(res);
            if (res.code == 1) {
                console.log(res.resultItemList);
                $('.kdMsg').text(res.resultItemList[0].context);
                $('.ftime').text(res.resultItemList[0].ftime);
            } else {
                dlctipbox.show(res.msg);
            }
        })
        $('.mainBox').append(str);
        if (getUrlParam('status') == 2) { //待收货
            //$('.state').css('color', '#7cc0f0').text('待收货');
            $('.express').css('display', 'flex');
        } else if(getUrlParam('status') == 3){ //已完成
            //$('.state').css('color', '#999').text('已完成');
            $('.express').css('display', 'flex');
        }
    } else {
        dlctipbox.show(res.msg);
    }
})
// 快递
function express(_this) {
    location.href = 'http://gxzjj.j.xiaozhuschool.com/h5/gxzjj/supply/html/supply_logistics.html?orderNo=' + $(_this).data('id')
}
// 确认收货
$('body').on('click', '.main_btn', function() {
    if (getUrlParam('status') != 1) {
        dlc_request('/api/onlineOrder/updateOrderStatus', { "orderNo": getUrlParam('order'), "status": 3 }, function(res) {
            console.log(res);
            if (res.code == 1) {
                dlctipbox.show(res.msg);
                history.go(-1);
            } else {
                dlctipbox.show(res.msg);
            }
        })
    } else {
        dlctipbox.show('商品还没有发货');
    }
})
if (getUrlParam('status') == 3) {
    $('.main_btn').hide();
}
</script>